home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP13.ZIP / PATRON / IADVSINK.CPP < prev    next >
C/C++ Source or Header  |  1993-06-27  |  4KB  |  206 lines

  1. /*
  2.  * IADVSINK.CPP
  3.  *
  4.  * Implementation of the IAdviseSink interface for Patron's tenants.
  5.  *
  6.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  7.  *
  8.  * Kraig Brockschmidt, Software Design Engineer
  9.  * Microsoft Systems Developer Relations
  10.  *
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #include "patron.h"
  17.  
  18.  
  19. /*
  20.  * CImpIAdviseSink::CImpIAdviseSink
  21.  * CImpIAdviseSink::~CImpIAdviseSink
  22.  *
  23.  * Parameters (Constructor):
  24.  *  pTenant         LPTENANT of the tenant we're in.
  25.  *  punkOuter       LPUNKNOWN to which we delegate.
  26.  */
  27.  
  28. CImpIAdviseSink::CImpIAdviseSink(LPTENANT pTenant, LPUNKNOWN punkOuter)
  29.     {
  30.     m_cRef=0;
  31.     m_pTen=pTenant;
  32.     m_punkOuter=punkOuter;
  33.     return;
  34.     }
  35.  
  36. CImpIAdviseSink::~CImpIAdviseSink(void)
  37.     {
  38.     return;
  39.     }
  40.  
  41.  
  42.  
  43.  
  44. /*
  45.  * CImpIAdviseSink::QueryInterface
  46.  * CImpIAdviseSink::AddRef
  47.  * CImpIAdviseSink::Release
  48.  *
  49.  * Purpose:
  50.  *  IUnknown members for CImpIAdviseSink object.
  51.  */
  52.  
  53. STDMETHODIMP CImpIAdviseSink::QueryInterface(REFIID riid, LPVOID FAR *ppv)
  54.     {
  55.     return m_punkOuter->QueryInterface(riid, ppv);
  56.     }
  57.  
  58.  
  59. STDMETHODIMP_(ULONG) CImpIAdviseSink::AddRef(void)
  60.     {
  61.     ++m_cRef;
  62.     return m_punkOuter->AddRef();
  63.     }
  64.  
  65. STDMETHODIMP_(ULONG) CImpIAdviseSink::Release(void)
  66.     {
  67.     --m_cRef;
  68.     return m_punkOuter->Release();
  69.     }
  70.  
  71.  
  72.  
  73.  
  74. /*
  75.  * IAdviseSink::OnDataChange
  76.  *
  77.  * Unused since we don't IDataObject::Advise.
  78.  */
  79.  
  80. STDMETHODIMP_(void) CImpIAdviseSink::OnDataChange(LPFORMATETC pFEIn
  81.     , LPSTGMEDIUM pSTM)
  82.     {
  83.     return;
  84.     }
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. /*
  93.  * IAdviseSink::OnViewChange
  94.  *
  95.  * Purpose:
  96.  *  Notifes the advise sink that presentation data changed in the data
  97.  *  object to which we're connected providing the right time to update
  98.  *  displays using such presentations.
  99.  *
  100.  * Parameters:
  101.  *  dwAspect        DWORD indicating which aspect has changed.
  102.  *  lindex          LONG indicating the piece that changed.
  103.  *
  104.  * Return Value:
  105.  *  None
  106.  */
  107.  
  108. STDMETHODIMP_(void) CImpIAdviseSink::OnViewChange(DWORD dwAspect, LONG lindex)
  109.     {
  110.     //This only requires a repaint, which our tenant makes simple for us.
  111.     if (dwAspect==m_pTen->m_fe.dwAspect)
  112.         m_pTen->Repaint();
  113.  
  114.     m_pTen->m_pPG->m_fDirty=TRUE;
  115.     return;
  116.     }
  117.  
  118.  
  119.  
  120.  
  121.  
  122. /*
  123.  * IAdviseSink::OnRename
  124.  *
  125.  * Purpose:
  126.  *  Informs the advise sink that an IOleObject has been renamed, primarily
  127.  *  when its linked.
  128.  *
  129.  * Parameters:
  130.  *  pmk             LPMONIKER providing the new name of the object
  131.  *
  132.  * Return Value:
  133.  *  None
  134.  */
  135.  
  136. STDMETHODIMP_(void) CImpIAdviseSink::OnRename(LPMONIKER pmk)
  137.     {
  138.     /*
  139.      * As a container this is unimportant to us since it really
  140.      * tells the handler's implementation of IOleLink that the
  141.      * object's moniker has changed.  Since we get this call
  142.      * from the handler, we don't have to do anything ourselves.
  143.      */
  144.     return;
  145.     }
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152. /*
  153.  * IAdviseSink::OnSave
  154.  *
  155.  * Purpose:
  156.  *  Informs the advise sink that the OLE object has been saved
  157.  *  persistently.  The primary purpose of this is for containers that
  158.  *  want to make optimizations for objects that are not in a saved
  159.  *  state, so on this you have to disable such optimizations.
  160.  *
  161.  * Parameters:
  162.  *  None
  163.  *
  164.  * Return Value:
  165.  *  None
  166.  */
  167.  
  168. STDMETHODIMP_(void) CImpIAdviseSink::OnSave(void)
  169.     {
  170.     /*
  171.      * A Container has nothing to do here as this notification is only
  172.      * useful when we have an ADVFCACHE_ONSAVE advise set up, which
  173.      * we don't.  So we ignore it.
  174.      */
  175.     return;
  176.     }
  177.  
  178.  
  179.  
  180.  
  181.  
  182. /*
  183.  * IAdviseSink::OnClose
  184.  *
  185.  * Purpose:
  186.  *  Informs the advise sink that the OLE object has closed and is
  187.  *  no longer bound in any way.
  188.  *
  189.  * Parameters:
  190.  *  None
  191.  *
  192.  * Return Value:
  193.  *  None
  194.  */
  195.  
  196. STDMETHODIMP_(void) CImpIAdviseSink::OnClose(void)
  197.     {
  198.     /*
  199.      * This doesn't have anything to do with us again as it's only used
  200.      * to notify the handler's IOleLink implementation of the change
  201.      * in the object.  We don't have to do anything since we'll also
  202.      * get an IOleClientSite::OnShowWindow(FALSE) to tell us to repaint.
  203.      */
  204.     return;
  205.     }
  206.